var util = require('../../utils/util.js');
Page({
  data: {
    scroll: 0,
    mbg: 0,
    bbfbg: 0,
    abfbg: 0,
    blbg: 0,
    albg: 0,
    bdbg: 0,
    adbg: 0,
    btbg: 0,
    date: '',
    selectDate:'',
    endDate: '',
    nowbs: 0,
    flag: 1,
    selectTime:'凌晨',
    recordTime:[
      { time: '凌晨' }, { time: '早餐前' }, { time: '早餐后' }, { time: '午餐前' }, { time: '午餐后' }, { time: '晚饭前' }, { time: '晚饭后' }, { time: '睡觉前' }
    ],
  }, 
  onLoad: function (options) {
    this.getBSinfo();
    var DATE = util.formatDate(new Date());
    this.setData({
      endDate: DATE,
      date:DATE,
      selectDate:DATE,
      nowbs: this.data.mbg
    });
  }, 
    
   DateChange(e) {
    this.setData({
      date: e.detail.value
    })
  },
  scrollSteps(e) {
    this.setData({
      scroll: e.currentTarget.dataset.id
    })
  }, 
  getBSinfo:function(){
    var params = {
      searchDate :this.data.date
    }
    util.httpGet('/wx/bloodSugar',params,(res) => {
      if(res != null){
        this.setData({
          mbg: res.mbg?res.mbg:0,
          bbfbg: res.bbfbg?res.bbfbg:0,
          abfbg: res.abfbg?res.abfbg:0 ,
          blbg: res.blbg?res.blbg:0,
          albg: res.albg?res.albg:0,
          bdbg: res.bdbg?res.bdbg:0,
          adbg: res.adbg?res.adbg:0,
          btbg: res.btbg?res.btbg:0,
          flag: 0
          })
      }else{
        this.setData({
          mbg:0,bbfbg:0,abfbg:0,blbg:0,albg:0,bdbg:0,adbg:0,btbg:0,flag:1
        })
      }
    })
  },
  onShow:function(){
    // console.log(this.data.isGoodsList+'我是一个返回值')
  }
})